﻿using System;
using System.Collections.Generic;

namespace AIFSCMSClient
{
    public class RuleExpressionPredicate : IExpressionPredicate
    {
        Queue<string> buffer;

        public Queue<string> Buffer
        {
            get 
            {
                if (buffer == null)
                    buffer = new Queue<string>();

                return buffer; 
            }
            set { buffer = value; }
        }

        public RuleExpressionPredicate()
        {

        }

        private CriteriaBuilderResult<RuleExpressionPredicate> Create(string Oper, string Value)
        {
            Buffer.Enqueue(Oper);
            Buffer.Enqueue(Value);

            CriteriaBuilderResult<RuleExpressionPredicate> result = new CriteriaBuilderResult<RuleExpressionPredicate>(Buffer);
            return result;
        }

        public CriteriaBuilderResult<RuleExpressionPredicate> IsEqualTo(string value)
        {
            return Create("=", value);
        }

        public CriteriaBuilderResult<RuleExpressionPredicate> IsNull()
        {
            return Create("=", "NULL");
        }

        public CriteriaBuilderResult<RuleExpressionPredicate> IsGreaterThan(string value)
        {
            return Create(">", value);
        }

        public CriteriaBuilderResult<RuleExpressionPredicate> IsGreaterThanEqualTo(string value)
        {
            return Create(">=", value);
        }

        public CriteriaBuilderResult<RuleExpressionPredicate> IsLessThan(string value)
        {
            return Create("<", value);
        }

        public CriteriaBuilderResult<RuleExpressionPredicate> IsLessThanEqualTo(string value)
        {
            return Create("<=", value);
        }
    }
}
